<template>
  <!-- 大客户项目报备管理  -审批明细-->
  <!-- <div class="wrapper">
    <Anchor :labelList="labels" activeId="row-01" labelWidth="130">
      <div class="line" id="row-01"> -->
        <div>
        <!-- 基本信息 -->
        <!-- <div style="height:100px;"> -->
             <BreakSpace label="项目信息" :containerStyle="{ marginBottom: '10px' }" />
          <FormPanel
            :list="initForm"
            :cols="3"
            formType="show"
            :labelWidth="90"
            :isSubmitBtn="false"
            @formChange="formChangeHandle"
            class="mtop"
          />
        <!-- </div>
      </div>
      <div class="line" id="row-02"> -->
        <!-- <div style="height:300px;"> -->
             <BreakSpace label="战败信息" :containerStyle="{ marginBottom: '10px' }" />
          <FormPanel
            ref="formPanel"
            :list="initForm2"
            :cols="3"
            :labelWidth="90"
            :isSubmitBtn="false"
            @formChange="formChangeHandle2"
            class="mtop"
          />
        <!-- </div>
      </div>
      <div class="line" id="row-03"> -->
           <BreakSpace label="跟进历史" :containerStyle="{ marginBottom: '10px' }" />
        <HistoryInfo v-model="val" :infoBasic="infoType" />
      <!-- </div>
      <div class="line" id="row-04"> -->
           <BreakSpace label="战败\延续记录" :containerStyle="{ marginBottom: '10px' }" />
        <FailureRecondInfo v-model="val" :infoBasic="infoType" />
      <!-- </div>
    </Anchor> -->
        <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDialog">关 闭</el-button>
    </div>
  </div>
</template>

<script>
import { getDealerCompanyByCode } from '@/api/common/org/dealerCompany';
import { authority } from '@/utils/authMixin';
import { dictionary } from '@/utils/dictMixin';
import BasicInfo from './infoBase'; //基本信息
import FailureInfo from './infoFailure'; //战败信息
import HistoryInfo from './infoHistory'; //跟进历史
import FailureRecondInfo from './infofailureRecond'; //战败/延续记录
import { updateFailure } from '@/api/cms-api/customerManage/continueManage/failure/index';
export default {
  name: 'DealerCompany',
  mixins: [authority, dictionary],
  components: {
    BasicInfo,
    HistoryInfo,
    FailureInfo,
    FailureRecondInfo
  },
  props: {
    rowData: {
      type: Object,
      default: () => ({})
    },
    infoType: {
      type: String,
      required: true
    }
  },
  created() {
    this.init();
  },
  data() {
    return {
      initForm: this.initFormFun(),
      initForm2: this.initFormFun2(),
      applyId: this.rowData.applyId,
      val: this.rowData.projectId,
      labels: [{ title: '项目信息', id: 'row-01' }, { title: '战败信息', id: 'row-02' }, { title: '跟进历史', id: 'row-03' }, { title: '战败/延续记录', id: 'row-04' }],
      formData: {}
    };
  },
  methods: {
    init() {
      console.log('数据---->', this.formData);
      console.log('2222---', this.rowData);
      //赋值
      this.initForm.forEach(x => {
        x.initialValue = this.rowData[x.fieldName];
      });
      this.initForm2.forEach(x => {
        x.initialValue = this.rowData[x.fieldName];
      });
    },
    formChangeHandle(val) {
      this.formValue = val;
    },
    formChangeHandle2(val) {
      this.formValue = val;
    },
    //搜索数据
    initFormFun2() {
      return [
        {
          type: 'SELECT',
          label: '战败类型',
          fieldName: 'defeatType',
          initialValue: '',
          disabled: true,
          itemList: this.createDictList('2523')
        },
        {
          type: 'DATE',
          label: '申请时间',
          fieldName: 'applyDate',
          valueFormat: 'yyyy-MM-dd HH:mm:ss',
          style: { width: '100%' },
          disabled: true,
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '战败品牌',
          fieldName: 'defeatBrandName',
          disabled: true,
          initialValue: ''
        },
        {
          type: 'SELECT',
          label: '战败车型',
          fieldName: 'defeatModelName',
          initialValue: '',
          disabled: true,
          itemList: this.createDictList('1008')
        },
        {
          type: 'TEXT_AREA',
          label: '战败原因',
          fieldName: 'applyReason',
          rows: 1,
          disabled: true,
          initialValue: ''
        },
        {
          type: 'TEXT_AREA',
          label: '审批意见',
          fieldName: 'checkDesc',
          rows: 2,
          initialValue: '',
          disabled: true
        }
      ];
    },
    //搜索数据
    initFormFun() {
      return [
        {
          type: 'INPUT',
          label: '客户公司名称',
          fieldName: 'customerName',
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '项目名称',
          fieldName: 'projectName',
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '项目编号',
          fieldName: 'projectCode',
          initialValue: ''
        },
        {
          type: 'DATE',
          label: '项目生效日期',
          fieldName: 'projectStartDate',
          valueFormat: 'yyyy-MM-dd HH:mm:ss',
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '经销商',
          fieldName: 'dealerName',
          initialValue: ''
        }
      ];
    },
    //保存
    async saveDialog() {
      this.$refs.formPanel.SUBMIT_FORM();
      console.log('sssss----------', this.formValue);
      console.log('zzz----------', this.applyId);
      let param = { checkDesc: this.formValue['checkDesc'] };
      param = Object.assign({}, param, { applyStatus: '25241003' });
      this.res = await updateFailure(param, this.applyId);
      //this.fetchParams = { ...this.fetchParams }; //刷新
      this.$emit('close', { visible: false });
    },
    //保存
    async saveDialog2() {
      this.$refs.formPanel.SUBMIT_FORM();
      console.log('sssss----------', this.formValue);
      console.log('zzz----------', this.applyId);
      let param = { checkDesc: this.formValue['checkDesc'] };
      param = Object.assign({}, param, { applyStatus: '25241002' });
      this.res = await updateFailure(param, this.applyId);
      //this.fetchParams = { ...this.fetchParams }; //刷新
      this.$emit('close', { visible: false });
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false });
    }
  }
};
</script>

<style scoped>
.wrapper {
  height: calc(100vh - 110px);
}
</style>
